package threadstart;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : ThreadDemo4
 * @Author : 54061
 * @Date: 2022/2/15 14:59
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        //创建3个线程对象
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName() + i);
                }
            }
        }, "汽车: ");
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName() + i);
                }
            }
        }, "火车: ");
        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName() + i);
                }
            }
        }, "飞机: ");

        //设置优先级
        t1.setPriority(1);
        t2.setPriority(5);
        t3.setPriority(10);

        //启动
        t1.start();
        t2.start();
        t3.start();
    }
}